package com.ebupt.login

import android.util.Log
import androidx.lifecycle.MutableLiveData
import com.blankj.utilcode.util.LogUtils
import com.ebupt.common.net.ktx.serverData
import com.ebupt.service.*

class LoginRepo(private val loginService:ILoginService):ILoginRepo {


    override var netResponse: MutableLiveData<List<KnowledgeSystem>> = MutableLiveData<List<KnowledgeSystem>>()


    override suspend fun userLogin(userName: String, psw: String) {
        loginService.userLogin()
            .serverData()
            .onSuccess {
                onBizOk { code, data, message ->
                    Log.e("NET","大小 ："+data?.size)
                    netResponse.value = data
                }

                onBizFail { code, message ->
                    Log.e("NET","message ："+message)
                    netResponse.value = null
                }

            }
            .onFailure {
                Log.e("NET",it.message)
                netResponse.value = null
            }
    }
}